Exemplo n.º 1
0
 /**
  * Remove a profile template to this network
  *
  * @param object ProfileTemplate object
  *
  * @return void
  *
  * @access public
  */
 public function removeProfileTemplate(ProfileTemplate $profile_template)
 {
     $db = AbstractDb::getObject();
     $profile_template_id = $db->escapeString($profile_template->getId());
     $sql = "DELETE FROM network_has_profile_templates WHERE network_id='{$this->_id}' AND profile_template_id='{$profile_template_id}'";
     $db->execSqlUpdate($sql, false);
 }
 /**
  * This method will create a ProfileTemplateField based on the content type filter specified
  *
  * @param string $user_prefix                A identifier provided by the programmer to
  *                                           recognise it's generated form
  * @param string $profile_template              Must be present
  *
  * @return object The ProfileTemplateField object, or null if the user didn't create one
  * @static
  */
 public static function processCreateFieldUI($user_prefix, ProfileTemplate $profile_template)
 {
     $db = AbstractDb::getObject();
     // Init values
     $profile_template_field_object = null;
     $max_display_order_row = null;
     $name = "get_new_profile_template_field_{$user_prefix}_add";
     if (!empty($_REQUEST[$name])) {
         /* Get the display order to add the ProfileTemplateField at the end */
         $sql = "SELECT MAX(display_order) as max_display_order FROM profile_template_fields WHERE profile_template_id = '" . $profile_template->getId() . "'";
         $db->execSqlUniqueRes($sql, $max_display_order_row, false);
         $display_order = $max_display_order_row['max_display_order'] + 1;
         $profile_template_field_id = get_guid();
         $sql = "INSERT INTO profile_template_fields (profile_template_field_id, profile_template_id, display_order) VALUES ('{$profile_template_field_id}', '{$profile_template->getId()}', {$display_order});";
         if (!$db->execSqlUpdate($sql, false)) {
             throw new Exception(_('Unable to insert new content into database!'));
         }
         $profile_template_field_object = self::getObject($profile_template_field_id);
         $name = "get_new_profile_template_field_{$user_prefix}_content_type_filter";
         $content_type_filter_ui_result = FormSelectGenerator::getResult($name, null);
         if (empty($content_type_filter_ui_result)) {
             throw new exception("Unable to retrieve the content type filter to associate with the new field");
         }
         $content_type_filter = ContentTypeFilter::getObject($content_type_filter_ui_result);
         $profile_template_field_object->replaceContentTypeFilter($content_type_filter);
     }
     return $profile_template_field_object;
 }