/**
 * Delete group relations if user is deleted
 *
 * @param  (object) $group Group Entity
 *
 * @return bool
 */
function ossn_delete_group_relations($group)
{
    if ($group) {
        $delete = new OssnDatabase();
        $params['from'] = 'ossn_relationships';
        //delete group member requests if group deleted
        $params['wheres'] = array("relation_from='{$group->guid}' AND type='group:join:approve' OR", "relation_to='{$group->guid}' AND type='group:join'");
        if ($delete->delete($params)) {
            return true;
        }
    }
    return false;
}
 /**
  * Delete component
  *
  * @return boolean
  */
 public function delete($com)
 {
     if (in_array($com, $this->requiredComponents())) {
         return false;
     }
     $component = $this->getbyName($com);
     if (!$component) {
         return false;
     }
     $params = array();
     $params['from'] = "ossn_components";
     $params['wheres'] = array("com_id='{$com}'");
     if (parent::delete($params)) {
         //Delete component settings upon its deletion #538
         $entities = new OssnEntities();
         $entities->deleteByOwnerGuid($component->id, 'component');
         //delete component directory
         OssnFile::DeleteDir(ossn_route()->com . "{$com}/");
         return true;
     }
     return false;
 }
Exemple #3
0
 /**
  * Delete component
  *
  * @return boolean
  */
 public function delete($com)
 {
     if (in_array($com, $this->requiredComponents())) {
         return false;
     }
     $params = array();
     $params['from'] = "ossn_components";
     $params['wheres'] = array("com_id='{$com}'");
     if (parent::delete($params)) {
         OssnFile::DeleteDir(ossn_route()->com . "{$com}/");
         return true;
     }
     return false;
 }
 * @package   (Informatikon.com).ossn
 * @author    OSSN Core Team <*****@*****.**>
 * @copyright 2014 iNFORMATIKON TECHNOLOGIES
 * @license   General Public Licence http://www.opensource-socialnetwork.org/licence
 * @link      http://www.opensource-socialnetwork.org/licence
 */
//This upgrade might timeout, so set no time limit
set_time_limit(0);
//Please see: Things , should be provided in 3.x #421
$database = new OssnDatabase();
//delete a notification that have incorrect owner_guid
//1.) Remove old like:post:group:wall notification type
//2.) Remove old comments:post:group:wall type
$vars['from'] = 'ossn_notifications';
$vars['wheres'] = array("type = 'like:post:group:wall' OR type='comments:post:group:wall'");
$database->delete($vars);
//add new column to users table
//3.) Add time_created to ossn_users table
$database->statement("ALTER TABLE `ossn_users` ADD `time_created` INT(11) NOT NULL AFTER `activation`;");
$database->execute();
//ossn_object description text to longtext and title to text #459
//5.) ossn_object description text to longtext and title to text #459
$database->statement("ALTER TABLE `ossn_object` CHANGE `title` `title` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, \n\t\t\t\t\t CHANGE `description` `description` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;");
$database->execute();
//add last_cache and site_version in settings
$database->statement("INSERT INTO `ossn_site_settings` (`name`) VALUES ('last_cache')");
$database->execute();
$database->statement("INSERT INTO `ossn_site_settings` (`name`) VALUES ('site_version')");
$database->execute();
//update user time_created cloumn from user entites
$users = ossn_get_entities(array('type' => 'user', 'subtype' => 'gender', 'page_limit' => false));
$database->execute();
/**
 * Fix lenght of time_created
 *
 * @access private
 */
$database->statement("ALTER TABLE  `ossn_notifications` \n                      CHANGE  `time_created`  `time_created` INT( 11 ) NOT NULL ;");
$database->execute();
/**
 * Delete wrong relationships
 *
 * @access private
 */
$delete['from'] = 'ossn_relationships';
$delete['wheres'] = array("type='0'");
$database->delete($delete);
/**
 * Update processed updates in database so user cannot upgrade again and again.
 *
 * @access private
 */
$upgrade_json = array_merge(ossn_get_upgraded_files(), array($upgrade));
$upgrade_json = json_encode($upgrade_json);
$update['table'] = 'ossn_site_settings';
$update['names'] = array('value');
$update['values'] = array($upgrade_json);
$update['wheres'] = array("name='upgrades'");
$upgrade = str_replace('.php', '', $upgrade);
if ($database->update($update)) {
    ossn_trigger_message(ossn_print('upgrade:success', array($upgrade)), 'success');
} else {