Exemple #1
0
 public function submit()
 {
     // @todo search indexer on posts (reindex all in case the topic_access level has changed))
     $this->topic_subject_clean = titania_url::url_slug($this->topic_subject);
     parent::submit();
     // Hooks
     titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this);
 }
Exemple #2
0
 }
 // Changed permalink?
 if ($permalink != titania::$contrib->contrib_name_clean) {
     // We check permalink
     if (!$permalink) {
         // If they leave it blank automatically create it
         $permalink = titania_url::url_slug(titania::$contrib->contrib_name);
         $append = '';
         $i = 2;
         while (titania::$contrib->validate_permalink($permalink . $append) == false) {
             $append = '_' . $i;
             $i++;
         }
         $permalink = $permalink . $append;
     } elseif (titania_url::url_slug($permalink) !== $permalink) {
         $error[] = sprintf(phpbb::$user->lang['INVALID_PERMALINK'], titania_url::url_slug($permalink));
     } elseif (!titania::$contrib->validate_permalink($permalink)) {
         $error[] = phpbb::$user->lang['CONTRIB_NAME_EXISTS'];
     }
 }
 // Did we succeed or have an error?
 if (!sizeof($error)) {
     // Check for changes in the description or categories to file a report
     if (!titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate')) {
         $attention_message = array();
         // Changed description?
         $old_description = $contrib_clone->generate_text_for_edit();
         $old_description = $old_description['text'];
         $description = titania::$contrib->generate_text_for_edit();
         $description = $description['text'];
         if ($old_description != $description) {
                continue;
            }
            // Ignore things marked as new that do not have contributions in the queue
            if ($row['contrib_status'] == 0) {
                $sql = 'SELECT COUNT(revision_id) AS cnt FROM ' . $ariel_prefix . 'queue
					WHERE ' . phpbb::$db->sql_in_set('queue_status', array(1, 2, 3, 4)) . '
						AND contrib_id = ' . $row['contrib_id'];
                $result1 = phpbb::$db->sql_query($sql);
                $cnt = phpbb::$db->sql_fetchfield('cnt', $result1);
                phpbb::$db->sql_freeresult($result1);
                if (!$cnt) {
                    // Somebody changed the status manually to new, should have been 3
                    continue;
                }
            }
            $permalink = titania_url::url_slug($row['contrib_name']);
            $conflict = $cnt = false;
            do {
                $permalink_test = $cnt !== false ? $permalink . '_' . $cnt : $permalink;
                $sql = 'SELECT contrib_id FROM ' . TITANIA_CONTRIBS_TABLE . '
					WHERE contrib_name_clean = \'' . phpbb::$db->sql_escape($permalink_test) . '\'';
                $p_result = phpbb::$db->sql_query($sql);
                if (phpbb::$db->sql_fetchrow($p_result)) {
                    $conflict = true;
                    $cnt = $cnt === false ? 2 : $cnt + 1;
                } else {
                    $conflict = false;
                    $permalink = $permalink_test;
                }
                phpbb::$db->sql_freeresult($p_result);
            } while ($conflict == true);
$sql = 'SELECT * FROM ' . TITANIA_CONTRIBS_TABLE . ' WHERE contrib_type = ' . TITANIA_TYPE_TRANSLATION;
$result = phpbb::$db->sql_query($sql);
while ($row = phpbb::$db->sql_fetchrow($result)) {
    $contrib->__set_array($row);
    $contrib->delete();
}
phpbb::$db->sql_freeresult($result);
// All the language packs we'll need, we wont transfer inactive ones, they need to be cleaned up anyways
$sql = 'SELECT * FROM lang_packs WHERE display > 0 AND version = 3';
$result = $db->sql_query($sql);
// All the authors we'll need
$sql2 = 'SELECT * FROM lang_packs_authors WHERE lang_id IN ( SELECT lang_id FROM lang_packs WHERE display > 0 ) ';
$authors = $db->sql_fetchrowset($db->sql_query($sql2));
$i = 0;
while ($row = $db->sql_fetchrow($result)) {
    $permalink = titania_url::url_slug($row['english_name']);
    $conflict = $cnt = false;
    do {
        $permalink_test = $cnt !== false ? $permalink . '_' . $cnt : $permalink;
        $sql = 'SELECT contrib_id FROM ' . TITANIA_CONTRIBS_TABLE . '
			WHERE contrib_name_clean = \'' . phpbb::$db->sql_escape($permalink_test) . '\'';
        $p_result = phpbb::$db->sql_query($sql);
        if (phpbb::$db->sql_fetchrow($p_result)) {
            $conflict = true;
            $cnt = $cnt === false ? 2 : $cnt + 1;
        } else {
            $conflict = false;
            $permalink = $permalink_test;
        }
        phpbb::$db->sql_freeresult($p_result);
    } while ($conflict == true);
 public function validate($contrib_categories = array())
 {
     $error = array();
     if (utf8_clean_string($this->contrib_name) == '') {
         $error[] = phpbb::$user->lang['EMPTY_CONTRIB_NAME'];
     }
     if (!$this->contrib_type) {
         $error[] = phpbb::$user->lang['EMPTY_CONTRIB_TYPE'];
     } else {
         // Check for a valid type
         $valid_type = false;
         foreach (titania_types::$types as $type_id => $class) {
             if (!$class->acl_get('submit')) {
                 continue;
             }
             if ($this->contrib_type == $type_id) {
                 $valid_type = true;
                 break;
             }
         }
         if (!$valid_type) {
             $error[] = phpbb::$user->lang['EMPTY_CONTRIB_TYPE'];
         }
         if (!$contrib_categories) {
             $error[] = phpbb::$user->lang['EMPTY_CATEGORY'];
         } else {
             $categories = titania::$cache->get_categories();
             foreach ($contrib_categories as $category) {
                 if (!isset($categories[$category])) {
                     $error[] = phpbb::$user->lang['NO_CATEGORY'];
                 } else {
                     if ($categories[$category]['category_type'] != $this->contrib_type) {
                         $error[] = phpbb::$user->lang['WRONG_CATEGORY'];
                     }
                 }
             }
         }
     }
     if (!$this->contrib_desc) {
         $error[] = phpbb::$user->lang['EMPTY_CONTRIB_DESC'];
     }
     if (defined('TITANIA_TYPE_TRANSLATION') && $this->contrib_type == TITANIA_TYPE_TRANSLATION && !$this->contrib_iso_code) {
         $error[] = phpbb::$user->lang['EMPTY_CONTRIB_ISO_CODE'];
     }
     if (defined('TITANIA_TYPE_TRANSLATION') && $this->contrib_type == TITANIA_TYPE_TRANSLATION && !$this->contrib_local_name) {
         $error[] = phpbb::$user->lang['EMPTY_CONTRIB_LOCAL_NAME'];
     }
     if (!$this->contrib_id) {
         if (!$this->contrib_name_clean) {
             // If they leave it blank automatically create it
             $this->contrib_name_clean = titania_url::url_slug($this->contrib_name);
             $append = '';
             $i = 2;
             while ($this->validate_permalink($this->contrib_name_clean . $append) == false) {
                 $append = '_' . $i;
                 $i++;
             }
             $this->contrib_name_clean = $this->contrib_name_clean . $append;
         } elseif (titania_url::url_slug($this->contrib_name_clean) !== $this->contrib_name_clean) {
             $error[] = sprintf(phpbb::$user->lang['INVALID_PERMALINK'], titania_url::url_slug($this->contrib_name_clean));
         } elseif (!$this->validate_permalink($this->contrib_name_clean)) {
             $error[] = phpbb::$user->lang['CONTRIB_NAME_EXISTS'];
         }
     }
     // Hooks
     titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $error, $this);
     return $error;
 }