/** * Create a translation of a phrase. If the phrase ID is set in the * constructor, we assume that the phrase already exists and we are * just creating a translation, and not a new phrase. * * @param string $p_text * Optional. The translation text. * @return boolean */ public function create($p_text = null) { if (!isset($this->m_data['phrase_id'])) { $this->m_data['phrase_id'] = Translation::__GeneratePhraseId(); } return parent::create(array("translation_text" => $p_text)); }
/** * Create the language. Creates the directory on disk to store the * translation files. * * @param array $p_values * @return mixed * Return TRUE on success and PEAR_Error on failure. */ public function create($p_values = null) { $success = parent::create($p_values); if ($success) { CampCache::singleton()->clear('user'); } return $success; }
public function create($p_article_no) { if (empty($p_article_no)) { return false; } $columns['fk_article_no'] = (int) $p_article_no; $result = parent::create($columns); return $result; }
/** * Create an issue. * @param string $p_shortName * @param array $p_values * @return boolean */ public function create($p_shortName, $p_values = null) { $tmpValues = array('ShortName' => $p_shortName); if (!is_null($p_values)) { $tmpValues = array_merge($p_values, $tmpValues); } $success = parent::create($tmpValues); return $success; }
/** * @param string $p_name * @return bool */ public function create($p_name = null) { if (empty($p_name)) { return false; } $columns['type'] = (string) $p_name; $result = parent::create($columns); return $result; }
public function create($p_name, $p_version, $p_enabled = true) { // Create the record $this->m_data['Name'] = $p_name; $values = array('Version' => $p_version, 'Enabled' => $p_enabled ? 1 : 0); $success = parent::create($values); if (!$success) { return false; } }
/** * @param array $p_values * @return boolean */ public function create($p_values = null) { $success = parent::create($p_values); $publicationObj = new Publication($this->m_data['IdPublication']); if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('The default subscription time for ($1 "$2":$3) has been added.', getGS("Publication"), $publicationObj->getName(), $this->m_data['CountryCode']); Log::Message($logtext, null, 4); return $success; } // fn create
public function create($p_values = null) { $success = parent::create($p_values); if ($success) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Country $1 added', $this->m_data['Name']." (".$this->m_data['Code'].")"); Log::Message($logtext, null, 131); } return $success; } // fn create
/** * Create an link blogentry <-> topic record in the database. * * @return void */ function create() { global $g_ado_db; // Create the record $success = parent::create(); if (!$success) { return; } $CampCache = CampCache::singleton(); $CampCache->clear('user'); return true; } // fn create
/** * Create the language. Creates the directory on disk to store the * translation files. * * @param array $p_values * @return mixed * Return TRUE on success and PEAR_Error on failure. */ public function create($p_values = null) { $success = parent::create($p_values); if ($success) { $result = Localizer::CreateLanguageFiles($this->m_data['Code']); if (PEAR::isError($result)) { $this->delete(false); return $result; } CampCache::singleton()->clear('user'); } return $success; }
public function create($p_article_id, $p_track_id, $p_track_data) { if (empty($p_article_id) || empty($p_track_id) || empty($p_track_data)) { return false; } $values = array('article_id' => $p_article_id, 'track_id' => $p_track_id, 'track_data' => serialize($p_track_data)); $success = parent::create($values); if (!$success) { return false; } $CampCache = CampCache::singleton(); $CampCache->clear('user'); return true; }
/** * Create a new Section. * @param string $p_name * @param string $p_shortName */ public function create($p_name, $p_shortName, $p_columns = null) { if (!is_array($p_columns)) { $p_columns = array(); } $p_columns['Name'] = $p_name; $p_columns['ShortName'] = $p_shortName; $success = parent::create($p_columns); if ($success) { global $g_ado_db; $sql = "UPDATE `Sections` s" . " JOIN `Issues` AS i ON i.`IdPublication` = s.`IdPublication` AND i.`Number` = s.`NrIssue` AND i.`IdLanguage` = s.`IdLanguage`" . " SET `fk_issue_id` = i.`id` WHERE " . " s.`IdPublication` = " . $this->m_data['IdPublication'] . " AND s.`NrIssue` = " . $this->m_data['NrIssue'] . " AND s.`Number` = " . $this->m_data['Number'] . " AND s.`IdLanguage` = " . $this->m_data['IdLanguage']; $g_ado_db->Execute($sql); } return $success; }
/** * @param string $p_name * @return bool */ public function create($p_name) { if (empty($p_name)) { return false; } $columns['type'] = (string) $p_name; $result = parent::create($columns); if ($result) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logText = getGS('Author type "$1" created.', $p_name); Log::Message($logText, null, 175); } return $result; }
/** * Create the language. Creates the directory on disk to store the * translation files. * * @param array $p_values * @return mixed * Return TRUE on success and PEAR_Error on failure. */ public function create($p_values = null) { $success = parent::create($p_values); if ($success) { $result = Localizer::CreateLanguageFiles($this->m_data['Code']); if (PEAR::isError($result)) { $this->delete(false); return $result; } CampCache::singleton()->clear('user'); if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Language "$1" ($2) added', $this->m_data['Name'], $this->m_data['OrigName']); Log::Message($logtext, null, 101); } return $success; } // fn create
/** * Create an issue. * @param string $p_shortName * @param array $p_values * @return boolean */ public function create($p_shortName, $p_values = null) { $tmpValues = array('ShortName' => $p_shortName); if (!is_null($p_values)) { $tmpValues = array_merge($p_values, $tmpValues); } $success = parent::create($tmpValues); if ($success) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Issue "$1" ($2) added in publication $3', $this->m_data['Name'], $this->m_data['Number'], $this->m_data['IdPublication']); Log::Message($logtext, null, 11); } return $success; } // fn create
/** * Create an link debate <-> publication record in the database. * * @return void */ function create() { global $g_ado_db; // Create the record $success = parent::create(); if (!$success) { return; } /* if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Debate Id $1 created.', $this->m_data['IdDebate']); Log::Message($logtext, null, 31); */ $CampCache = CampCache::singleton(); $CampCache->clear('user'); return true; }
/** * Create a new Section. * @param string $p_name * @param string $p_shortName */ public function create($p_name, $p_shortName, $p_columns = null) { if (!is_array($p_columns)) { $p_columns = array(); } $p_columns['Name'] = $p_name; $p_columns['ShortName'] = $p_shortName; $success = parent::create($p_columns); if ($success) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Section "$1" ($2) added. (Publication: $3, Issue: $4)', $this->m_data['Name'], $this->m_data['Number'], $this->m_data['IdPublication'], $this->m_data['NrIssue']); Log::Message($logtext, null, 21); } return $success; } // fn create
/** * Create an poll answer in the database. Use the SET functions to * change individual values. * * @param string $p_fk_default_language_id * @param date $p_date_begin * @param date $p_date_end * @param int $p_nr_of_answers * @param bool $p_is_show_after_expiration * @return void */ function create($p_answer) { global $g_ado_db; if (!strlen($p_answer)) { return false; } // Create the record $values = array('answer' => $p_answer); $success = parent::create($values); if (!$success) { return; } /* if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Poll Id $1 created.', $this->m_data['IdPoll']); Log::Message($logtext, null, 31); */ $CampCache = CampCache::singleton(); $CampCache->clear('user'); return true; }
function create($p_user_id, $p_language_id, $p_title, $p_info, $p_request_text, $p_feature) { // Create the record $values = array( 'fk_user_id' => $p_user_id, 'fk_language_id'=> $p_language_id, 'title' => $p_title, 'info' => $p_info, 'request_text' => $p_request_text, 'feature' => $p_feature, 'date' => date('Y-m-d H:i:s') ); $success = parent::create($values); if (!$success) { return false; } $this->fetch(); $CampCache = CampCache::singleton(); $CampCache->clear('user'); return true; }
/** * Create an poll in the database. Use the SET functions to * change individual values. * * @param date $p_date_begin * @param date $p_date_end * @param int $p_nr_of_answers * @param bool $p_votes_per_user * @return void */ public function create($p_title, $p_question, $p_date_begin, $p_date_end, $p_nr_of_answers, $p_votes_per_user) { global $g_ado_db; if (!strlen($p_title) || !strlen($p_question) || !$p_date_begin || !$p_date_end || !$p_nr_of_answers) { return false; } $this->m_data['poll_nr'] = $this->generatePollNumber(); // Create the record $values = array('date_begin' => $p_date_begin, 'date_end' => $p_date_end, 'nr_of_answers' => $p_nr_of_answers, 'title' => $p_title, 'question' => $p_question, 'votes_per_user' => $p_votes_per_user); $success = parent::create($values); if (!$success) { return false; } /* if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Poll Id $1 created.', $this->m_data['IdPoll']); Log::Message($logtext, null, 31); */ $CampCache = CampCache::singleton(); $CampCache->clear('user'); return true; }
/** * Create the publication. * * This is a wrapper around DatabaseObject::create(), * but also logs a message and notifies the Parser. * * @param array $p_values * @return boolean */ public function create($p_values = null) { $created = parent::create($p_values); return $created; }
/** * Create a ban item. * * @param int $p_type * Can be one of: * PHORUM_BAD_IPS * PHORUM_BAD_NAMES * PHORUM_BAD_EMAILS * PHORUM_BAD_WORDS * PHORUM_BAD_USERID * PHORUM_BAD_SPAM_WORDS * * @param boolean $p_isRegex * Set to TRUE if $p_matchString is a regular expression, * set to FALSE if it isnt. * * @param string $p_matchString * String to match to see if something is banned. * * @param int $p_forumId * If the forum ID is set to zero, the ban will apply to all forums. * If it is set to a number greater that zero (a forum ID), * then the ban will only apply to that forum. * * @return boolean */ public function create($p_type, $p_isRegex, $p_matchString, $p_forumId = 0) { global $PHORUM; if (!is_numeric($p_type) || !is_numeric($p_forumId) || !in_array($p_type, $this->m_allowedTypes)) { return false; } $p_isRegex = $p_isRegex ? "1": "0"; // if ($p_type == PHORUM_BAD_IPS) { // // Fetch the settings and pretend they were returned to // // us instead of setting a global variable. // phorum_db_load_settings(); // $settings = $PHORUM['SETTINGS']; // // // Lookup the IP address, convert to hostname // if ($settings["dns_lookup"]) { // $resolved = @gethostbyaddr($p_matchString); // if (!empty($resolved) && ($resolved != $p_matchString) ) { // $p_matchString = $resolved; // } // } // } // Check if this ban item already exists $repeats = Phorum_ban_item::GetBanItems($p_type, $p_isRegex, $p_matchString, $p_forumId); // Add it if it doesnt exist if (count($repeats) == 0) { $columns = array("type" => $p_type, "forum_id" => $p_forumId, "string" => $p_matchString, "pcre" => $p_isRegex); $success = parent::create($columns); return $success; } return true; } // fn create
/** * Create an article in the database. Use the SET functions to * change individual values. * * If you would like to "place" the article using the publication ID, * issue number, and section number, you can only do so if all three * of these parameters are present. Otherwise, the article will remain * unplaced. * * @param string $p_articleType * @param string $p_name * @param int $p_publicationId * @param int $p_issueNumber * @param int $p_sectionNumber * @return void */ public function create($p_articleType, $p_name = null, $p_publicationId = null, $p_issueNumber = null, $p_sectionNumber = null) { global $g_ado_db; $this->m_data['Number'] = $this->__generateArticleNumber(); $this->m_data['ArticleOrder'] = $this->m_data['Number']; // Create the record $values = array(); if (!is_null($p_name)) { $values['Name'] = $p_name; } // Only categorize the article if all three arguments: // $p_publicationId, $p_issueNumber, and $p_sectionNumber // are present. if (is_numeric($p_publicationId) && is_numeric($p_issueNumber) && is_numeric($p_sectionNumber) && ($p_publicationId > 0) && ($p_issueNumber > 0) && ($p_sectionNumber > 0) ) { $values['IdPublication'] = (int)$p_publicationId; $values['NrIssue'] = (int)$p_issueNumber; $values['NrSection'] = (int)$p_sectionNumber; } $values['ShortName'] = $this->m_data['Number']; $values['Type'] = $p_articleType; $values['Public'] = 'Y'; if (!is_null($p_publicationId) && $p_publicationId > 0) { $where = " WHERE IdPublication = $p_publicationId AND NrIssue = $p_issueNumber" . " and NrSection = $p_sectionNumber"; } else { $where = ''; } // compute article order number $queryStr = "SELECT MIN(ArticleOrder) AS min FROM Articles$where"; $articleOrder = $g_ado_db->GetOne($queryStr); if (is_null($articleOrder) || !isset($values['NrSection'])) { $articleOrder = $this->m_data['Number']; } else { $increment = $articleOrder > 0 ? 1 : 2; $queryStr = "UPDATE Articles SET ArticleOrder = ArticleOrder + $increment $where"; $g_ado_db->Execute($queryStr); $articleOrder = 1; } $values['ArticleOrder'] = $articleOrder; $success = parent::create($values); if (!$success) { return; } $this->fetch(); $this->setProperty('UploadDate', 'NOW()', true, true); // Insert an entry into the article type table. $articleData = new ArticleData($this->m_data['Type'], $this->m_data['Number'], $this->m_data['IdLanguage']); $articleData->create(); if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } Log::ArticleMessage($this, getGS('Article created.'), null, 31, TRUE); } // fn create
/** * Create a column in the table. * @param string $p_type * Can be one of: 'text', 'date', 'body', 'switch', 'numeric'. */ public function create($p_type, array $p_params = array()) { global $g_ado_db; $p_type = strtolower($p_type); $numericPrecision = isset($p_params['precision']) ? $p_params['precision'] : null; $types = self::DatabaseTypes(null, $numericPrecision); if ($this->getPrintName() != 'NULL' && !array_key_exists($p_type, $types)) { return false; } if ($p_type == self::TYPE_TOPIC && $this->getPrintName() != 'NULL') { if (!isset($p_params['root_topic_id']) && !is_numeric($p_params['root_topic_id'])) { return false; } $rootTopicId = (int) $p_params['root_topic_id']; $queryStr2 = "INSERT INTO TopicFields (ArticleType, FieldName, RootTopicId) " . "VALUES (" . $g_ado_db->escape($this->m_data['type_name']) . ", " . $g_ado_db->escape($this->m_data['field_name']) . ", '{$rootTopicId}')"; if (!$g_ado_db->Execute($queryStr2)) { return false; } } if ($this->getPrintName() != 'NULL') { $queryStr = "ALTER TABLE `X" . $this->m_data['type_name'] . "` ADD COLUMN `" . $this->getName() . '` ' . $types[$p_type]; $success = $g_ado_db->Execute($queryStr); } if ($this->getPrintName() == 'NULL' || $success) { $data = array(); if ($this->getPrintName() != 'NULL') { if ($p_type == self::TYPE_BODY && isset($p_params['is_content'])) { $data['is_content_field'] = (int) $p_params['is_content']; } if ($p_type == self::TYPE_BODY && isset($p_params['editor_size'])) { $data['field_type_param'] = 'editor_size=' . $p_params['editor_size']; } if ($p_type == self::TYPE_NUMERIC && isset($p_params['precision'])) { $data['field_type_param'] = 'precision=' . (int) $p_params['precision']; } if ($p_type == self::TYPE_TEXT && isset($p_params['maxsize'])) { $data['max_size'] = (int) $p_params['maxsize']; } $data['field_type'] = $p_type; $data['field_weight'] = $this->getNextOrder(); } $success = parent::create($data); } if ($success) { if ($p_type == self::TYPE_COMPLEX_DATE && isset($p_params['event_color'])) { $success = $this->setColor($p_params['event_color']); } } if ($success) { CampCache::singleton()->clear('user'); } return $success; }
/** * Create an interview in the database. Use the SET functions to * change individual values. * * @param date $p_date_begin * @param date $p_date_end * @param int $p_nr_of_answers * @param bool $p_is_show_after_expiration * @return void */ public function create($p_fk_questioneer_user_id = null, $p_question = null, $p_status = 'draft') { global $g_ado_db; $this->m_data['item_id'] = NULL; // fix position generating // Create the record $values = array( 'fk_questioneer_user_id' => $p_fk_questioneer_user_id, 'question' => $p_question, 'status' => $p_status ); $success = parent::create($values); if (!$success) { return false; } $query = " SELECT MAX(position) + 1 AS next FROM {$this->m_dbTableName} WHERE fk_interview_id = {$this->m_data['fk_interview_id']}"; $max = $g_ado_db->getRow($query); // Set position $query = " UPDATE {$this->m_dbTableName} SET position = {$max['next']} WHERE item_id = {$this->m_data['item_id']}"; $res = $g_ado_db->execute($query); /* if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Poll Id $1 created.', $this->m_data['IdPoll']); Log::Message($logtext, null, 31); */ $CampCache = CampCache::singleton(); $CampCache->clear('user'); return true; } // fn create
/** * Create a forum. * * @return boolean */ public function create() { $columns = array( 'moderation'=>0, 'email_moderators'=>0, 'pub_perms'=>1, 'reg_perms'=>15, // display 'display_fixed'=>0, // display 'template'=>'default', // ??? 'language'=>'english', // display 'threaded_list'=>0, // display 'threaded_read'=>0, // display 'reverse_threading'=>0, // retreive 'float_to_top'=>1, // Display // Used in phorum_db_get_thread_list() to determine how // many threads to show on a page. 'list_length_flat'=>30, 'list_length_threaded'=>15, // Used in phorum_db_get_messages() - // max number of messages to get. 'read_length'=>30, 'display_ip_address'=>0, 'allow_email_notify'=>0, // Whether to check for duplicates when posting a message. // 0 => false // 1 => true 'check_duplicate'=>1, // Count the number of times each message has been viewed // 0 => "No" // 1 => "Yes, show views added to subject" // 2 => "Yes, show views as extra column" 'count_views'=>2, 'max_attachments'=>0, 'allow_attachment_types'=>'', 'max_attachment_size'=>0, 'max_totalattachment_size'=>0, // Virtual root folder 'vroot'=>0); parent::create($columns); } // fn create
/** * @param array $p_values * @return boolean */ public function create($p_values = null) { $success = parent::create($p_values); $publicationObj = new Publication($this->m_data['IdPublication']); return $success; }
/** * Create an article in the database. Use the SET functions to * change individual values. * * If you would like to "place" the article using the publication ID, * issue number, and section number, you can only do so if all three * of these parameters are present. Otherwise, the article will remain * unplaced. * * @param string $p_articleType * @param string $p_name * @param int $p_publicationId * @param int $p_issueNumber * @param int $p_sectionNumber * @return void */ public function create($p_articleType = null, $p_name = null, $p_publicationId = null, $p_issueNumber = null, $p_sectionNumber = null) { global $g_ado_db; $translator = \Zend_Registry::get('container')->getService('translator'); $this->m_data['Number'] = $this->__generateArticleNumber(); $this->m_data['ArticleOrder'] = $this->m_data['Number']; // Create the record $values = array(); if (!is_null($p_name)) { $values['Name'] = $p_name; } // Only categorize the article if all three arguments: // $p_publicationId, $p_issueNumber, and $p_sectionNumber // are present. if (is_numeric($p_publicationId) && is_numeric($p_issueNumber) && is_numeric($p_sectionNumber) && $p_publicationId > 0 && $p_issueNumber > 0 && $p_sectionNumber > 0) { $values['NrIssue'] = (int) $p_issueNumber; $values['NrSection'] = (int) $p_sectionNumber; } $values['ShortName'] = $this->m_data['Number']; $values['Type'] = $p_articleType; $values['Public'] = 'Y'; $values['IdPublication'] = (int) $p_publicationId; if (!is_null($p_publicationId) && $p_publicationId > 0) { $where = " WHERE IdPublication = {$p_publicationId} AND NrIssue = {$p_issueNumber}" . " and NrSection = {$p_sectionNumber}"; } else { $where = ''; } // compute article order number $queryStr = "SELECT MIN(ArticleOrder) AS min FROM Articles{$where}"; $articleOrder = $g_ado_db->GetOne($queryStr); if (is_null($articleOrder) || !isset($values['NrSection'])) { $articleOrder = $this->m_data['Number']; } else { $increment = $articleOrder > 0 ? 1 : 2; $queryStr = "UPDATE Articles SET ArticleOrder = ArticleOrder + {$increment} {$where}"; $g_ado_db->Execute($queryStr); $articleOrder = 1; } $values['ArticleOrder'] = $articleOrder; $success = parent::create($values); if (!$success) { return; } $this->fetch(); $this->setProperty('UploadDate', 'NOW()', true, true); // Insert an entry into the article type table. $articleData = new ArticleData($this->m_data['Type'], $this->m_data['Number'], $this->m_data['IdLanguage']); $articleData->create(); $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache'); $cacheService->clearNamespace('article'); Log::ArticleMessage($this, $translator->trans('Article created.', array(), 'api'), null, 31, TRUE); }
/** * I am checking if the instance's username and password are empty because * I am running this function in the __construct() which will get called when * instantiate() gets called which I do not want because no values are passed * in for the __construct() and therefore it would insert a blank user into my * database every time. * * If there was a successful create then the instance's id get set to whatever * mysql gives back since it will auto increment in the database. * * To abstract the attributes I need to first return an associative array of * the key value pairings. * * I have found it easier to rewrite the CRUD for the user because I am using * a hashed password. * * @return boolean True on success and false on fail. */ protected function create() { global $db; // Don't forget the Sql syntax good habits // "INSERT INTO [table_name] (key, key, ...) VALUES ('value', 'value', ..) // single quote around the values so they are literal and then I will // escape all values with escape_string() to prevent sql injects" if (!empty($this->username) && !empty($this->password)) { return parent::create() ? true : false; } return false; }
public function create($p_userId, $p_startIP, $p_addresses = 1) { $startIP = null; $startIPstring = ''; if (!is_null($p_startIP)) { if (!is_array($p_startIP)) { $startIP = $this->__string2array($p_startIP); $startIPstring = $p_startIP; } else { $startIPstring = $this->__array2string($p_startIP); } $startIP = $this->__array2int($p_startIP); } $tmpValues = array('IdUser'=>$p_userId, 'StartIP'=>$startIP, 'Addresses'=>$p_addresses); $result = parent::create($tmpValues); if ($result) { $user = new User($p_userId); $logtext = getGS('IP Group $1 added for user $2', "$startIPstring:$p_addresses", $user->getUserName()); Log::Message($logtext, null, 57); } return $result; }