Code Duplication    Length = 24-24 lines in 2 locations

engine/classes/ElggGroup.php 1 location

@@ 522-545 (lines=24) @@
519
	/**
520
	 * {@inheritdoc}
521
	 */
522
	protected function create() {
523
		global $CONFIG;
524
		
525
		$guid = parent::create();
526
		if (!$guid) {
527
			// @todo this probably means permission to create entity was denied
528
			// Is returning false the correct thing to do
529
			return false;
530
		}
531
		
532
		$name = sanitize_string($this->name);
533
		$description = sanitize_string($this->description);
534
535
		$query = "INSERT into {$CONFIG->dbprefix}groups_entity"
536
			. " (guid, name, description) values ($guid, '$name', '$description')";
537
538
		$result = $this->getDatabase()->insertData($query);
539
		if ($result === false) {
540
			// TODO(evan): Throw an exception here?
541
			return false;
542
		}
543
		
544
		return $guid;
545
	}
546
547
	/**
548
	 * {@inheritdoc}

engine/classes/ElggObject.php 1 location

@@ 129-152 (lines=24) @@
126
	/**
127
	 * {@inheritdoc}
128
	 */
129
	protected function create() {
130
		global $CONFIG;
131
132
		$guid = parent::create();
133
		if (!$guid) {
134
			// @todo this probably means permission to create entity was denied
135
			// Is returning false the correct thing to do
136
			return false;
137
		}
138
		$title = sanitize_string($this->title);
139
		$description = sanitize_string($this->description);
140
		
141
		$query = "INSERT into {$CONFIG->dbprefix}objects_entity
142
			(guid, title, description) values ($guid, '$title', '$description')";
143
144
		$result = $this->getDatabase()->insertData($query);
145
		if ($result === false) {
146
			// TODO(evan): Throw an exception here?
147
			return false;
148
		}
149
150
		$this->enable();
151
		return $guid;
152
	}
153
154
	/**
155
	 * {@inheritdoc}