Ejemplo n.º 1
0
 function del()
 {
     $ids = I('ids');
     if (is_array($ids)) {
         $map['id'] = array('in', $ids);
         $result = delete_data($this->table, $map);
         $ids = implode(',', $ids);
         if ($result) {
             //action_log($this->table,$ids);
             $this->success('操作成功', U('index'));
         } else {
             $this->error($result);
         }
     } else {
         $ids = intval($ids);
         $map['id'] = $ids;
         $result = delete_data($this->table, $map);
         if ($result) {
             //action_log($this->table,$ids);
             $this->success('操作成功', U('index'));
         } else {
             $this->error($result);
         }
     }
 }
 public function praise_get()
 {
     $this->check_token();
     $table = 'praise';
     $table_name = 'information';
     $catid = I('get.id', 0, 'intval');
     $uid = $this->uid;
     // 27192;
     // 检测此赞是否存在
     $map = array('table_name' => $table_name, 'member_id' => $uid, 'catid' => $catid);
     $res = get_info($table, $map);
     if ($res) {
         // 取消赞
         $result = delete_data($table, array('id' => $res['id']));
         if ($result) {
             // 更新赞的数量
             update_num($table_name, array('id' => $catid), 'praise_num', 1, false);
             $msg = array('praise_status' => 2, 'msg' => '取消成功');
         } else {
             $this->error(1500);
         }
     } else {
         // 添加赞
         $_POST = array('table_name' => $table_name, 'member_id' => $uid, 'catid' => $catid);
         $result = update_data($table);
         if ($result) {
             // 更新赞的数量
             update_num($table_name, array('id' => $catid), 'praise_num', 1, true);
             $msg = array('praise_status' => 1, 'msg' => '添加成功');
         } else {
             $this->error(1500);
         }
     }
     $this->success($msg);
 }
Ejemplo n.º 3
0
 public function testCanDeleteData()
 {
     _elgg_services()->db->addQuerySpec(['sql' => 'DELETE FROM A WHERE b = :b', 'params' => [':b' => 'b'], 'row_count' => 20]);
     _elgg_services()->db->addQuerySpec(['sql' => 'DELETE FROM A WHERE c = :c', 'params' => [':c' => 'c']]);
     $this->assertEquals(20, delete_data('DELETE FROM A WHERE b = :b', [':b' => 'b']));
     $this->assertEquals(0, delete_data('DELETE FROM A WHERE c = :c', [':c' => 'c']));
 }
Ejemplo n.º 4
0
function deleteAll($db)
{
    $DELETED_MANUFACTER_CATEGORY = 2;
    //подключение к БД
    $link = $db->connectToDb();
    $table_prefix = $db->getTablePrefix() . $db->getVMTablePrefix();
    $query_parent_categories = "select category_child_id from " . $table_prefix . "category_categories where category_parent_id=0";
    $result = mysql_query($query_parent_categories, $link);
    $rows_num = mysql_num_rows($result);
    //if record doesn't exist insert record in tables
    if ($rows_num > 0) {
        while ($row = mysql_fetch_row($result)) {
            $category_nums[] = $row[0];
        }
    }
    $table_delete = array($table_prefix . "categories", $table_prefix . "categories_ru_ru", $table_prefix . "category_medias");
    $table_error .= delete_data($table_delete, "virtuemart_category_id not in('" . implode("','", $category_nums) . "')", $link);
    $table_delete = array($table_prefix . "category_categories");
    $table_error .= delete_data($table_delete, "category_child_id not in('" . implode("','", $category_nums) . "')", $link);
    $table_delete = array($table_prefix . "manufacturers_ru_ru", $table_prefix . "manufacturer_medias");
    $table_error .= delete_data($table_delete, "virtuemart_manufacturer_id in (SELECT virtuemart_manufacturer_id from " . $table_prefix . "manufacturers \nWHERE virtuemart_manufacturercategories_id=2)", $link);
    $table_delete = array($table_prefix . "manufacturers");
    $table_error .= delete_data($table_delete, "virtuemart_manufacturercategories_id=" . $DELETED_MANUFACTER_CATEGORY, $link);
    $table_delete = array($table_prefix . "import", $table_prefix . "products", $table_prefix . "products_ru_ru", $table_prefix . "product_categories", $table_prefix . "product_manufacturers", $table_prefix . "product_medias", $table_prefix . "product_relations", $table_prefix . "product_prices", $table_prefix . "product_shoppergroups", $table_prefix . "product_customfields");
    $table_error .= delete_data($table_delete, '1', $link);
    if ($table_error != '') {
        echo "<p style='color:red;'>" . 'При удалении возникли ошибки, таблицы: ' . $table_error . "</p>";
    } else {
        echo "<p style='color:blue;'>" . 'Удаление прошло успешно!' . "</p>";
    }
}
Ejemplo n.º 5
0
 /**
  * Revoke an api user key.
  *
  * @param string $api_key   The API Key (public)
  * @return bool
  */
 public function revoke($api_key)
 {
     $user = $this->get($api_key);
     if ($user) {
         return delete_data("DELETE from {$this->dbprefix}api_users\n\t\t\t\t\t\t\t\t\tWHERE id={$user->id}");
     }
     return false;
 }
Ejemplo n.º 6
0
function openid_server_delete_entity($entity)
{
    global $CONFIG;
    $entity->clearMetadata();
    $entity->clearAnnotations();
    $guid = $entity->getGUID();
    delete_data("DELETE from {$CONFIG->dbprefix}entities where guid={$guid}");
}
/**
 * Removes all items relating to a particular entity being acted upon from the river
 *
 * @param int $object_guid The GUID of the entity
 * @return true|false Depending on success
 */
function remove_from_river_by_object($object_guid)
{
    // Sanitise
    $object_guid = (int) $object_guid;
    // Load config
    global $CONFIG;
    // Remove
    return delete_data("delete from {$CONFIG->dbprefix}river where object_guid = {$object_guid}");
}
Ejemplo n.º 8
0
/**
 * Revoke an api user key.
 *
 * @param string $api_key   The API Key (public).
 *
 * @return bool
 */
function remove_api_user($api_key)
{
    $dbprefix = elgg_get_config('dbprefix');
    $keypair = get_api_user($api_key);
    if ($keypair) {
        return delete_data("DELETE from {$dbprefix}api_users where id={$keypair->id}");
    }
    return false;
}
Ejemplo n.º 9
0
/**
 * Revoke an api user key.
 *
 * @param int    $site_guid The GUID of the site.
 * @param string $api_key   The API Key (public).
 *
 * @return bool
 */
function remove_api_user($site_guid, $api_key)
{
    global $CONFIG;
    $keypair = get_api_user($site_guid, $api_key);
    if ($keypair) {
        return delete_data("DELETE from {$CONFIG->dbprefix}api_users where id={$keypair->id}");
    }
    return false;
}
/**
 * Unset a config option.
 *
 * @param string $name The name of the field.
 * @param int $site_guid Optionally, the GUID of the site (current site is assumed by default).
 * @return mixed
 */
function unset_config($name, $site_guid = 0)
{
    global $CONFIG;
    $name = mysql_real_escape_string($name);
    $site_guid = (int) $site_guid;
    if ($site_guid == 0) {
        $site_guid = (int) $CONFIG->site_id;
    }
    return delete_data("delete from {$CONFIG->dbprefix}config where name='{$name}' and site_guid={$site_guid}");
}
Ejemplo n.º 11
0
function upgrade_izap_videos_to($version)
{
    global $CONFIG;
    $update_entity_subtype = "UPDATE {$CONFIG->dbprefix}entity_subtypes SET class = 'IzapVideos' WHERE subtype = 'izap_videos'";
    $del_entity_query = "DELETE FROM {$CONFIG->dbprefix}entities\n                WHERE subtype IN (SELECT id FROM {$CONFIG->dbprefix}entity_subtypes\n                                  WHERE subtype='izapVideoQueue')";
    $del_queue_object_query = "DELETE FROM {$CONFIG->dbprefix}entity_subtypes where subtype='izapVideoQueue'";
    if (update_data($update_entity_subtype) || (delete_data($del_entity_query) || delete_data($del_queue_object_query))) {
        datalist_set('izap_videos_version', $version);
    }
}
Ejemplo n.º 12
0
 /**
  * Remove expired tokens
  * @return bool
  */
 public function removeExpiredTokens()
 {
     $time = time();
     $result = delete_data("DELETE FROM {$this->dbprefix}users_apisessions\n\t\t\t\t\t\t\t\tWHERE expires < {$time}");
     if (elgg_in_context('cron')) {
         if ($result !== false) {
             return "{$result} expired user tokens were removed" . PHP_EOL;
         } else {
             return "ERROR: Expired user tokens could not be removed" . PHP_EOL;
         }
     }
     return $result;
 }
Ejemplo n.º 13
0
 /**
 * Data Add
 *
 * @access system
 * @return return;
 */
 public static function Data($query, $type)
 {
     global $CONFIG;
     $query = str_replace('prefixes_', $CONFIG->dbprefix, $query);
     if (!empty($query) && $type == 'get') {
         return get_data($query);
     }
     if (!empty($query) && $type == 'delete') {
         return delete_data($query);
     }
     if (!empty($query) && $type == 'add') {
         return insert_data($query);
     }
     if (!empty($query) && $type == 'run') {
         return run_sql_script($query);
     }
 }
Ejemplo n.º 14
0
function subsite_manager_upgrade_system_handler($event, $type, $entity)
{
    if (get_input("all") == "true") {
        // find subsites and do stuff
        $options = array("type" => "site", "subtype" => Subsite::SUBTYPE, "limit" => false);
        // this could take a while
        set_time_limit(0);
        $batch = new ElggBatch("elgg_get_entities", $options);
        $viewtypes = elgg_get_config("view_types");
        $dataroot = elgg_get_config("dataroot");
        foreach ($batch as $subsite) {
            // clear simplecache
            $dir = $dataroot . "views_simplecache/" . $subsite->getGUID() . "/";
            if (file_exists($dir) && ($handle = opendir($dir))) {
                // remove files
                while (false !== ($file = readdir($handle))) {
                    if (!is_dir($dir . $file)) {
                        unlink($dir . $file);
                    }
                }
                closedir($handle);
            }
            if (!empty($viewtypes) && is_array($viewtypes)) {
                foreach ($viewtypes as $viewtype) {
                    datalist_set("sc_lastupdate_" . $viewtype . "_" . $subsite->getGUID(), 0);
                    datalist_set("sc_lastcached_" . $viewtype . "_" . $subsite->getGUID(), 0);
                }
            }
            // clear system cache
            $system_cache = new ElggFileCache($dataroot . "system_cache/" . $subsite->getGUID() . "/");
            $system_cache->clear();
            // cleanup cron cache
            $cron_cache = $dataroot . "subsite_manager/" . $subsite->getGUID() . "/cron_cache.json";
            if (file_exists($cron_cache)) {
                unlink($cron_cache);
            }
            // reset translation editor cache
            // can't use remove_private_setting because of 'name like' not 'name ='
            $sql = "DELETE FROM " . get_config("dbprefix") . "private_settings";
            $sql .= " WHERE name LIKE 'te_last_update_%'";
            $sql .= " AND entity_guid = " . $subsite->getGUID();
            delete_data($sql);
        }
    }
}
Ejemplo n.º 15
0
 public function del()
 {
     //1、根据点击删除传递过来的ID获取相关数据
     $ids = I('ids');
     $map['id'] = array("in", $ids);
     $result = get_result($this->table, $map);
     //2、获取评论内容中的图片并删除
     foreach ($result as $key => $value) {
         //删除内容中的图片
         delStrImgs($value['content']);
         //3、统计评论删除后新闻的评论数量
         $_POST['id'] = $value['product_id'];
         $_POST['comment'] = count_data($this->table, array("product_id" => $value['product_id']));
         update_data("article");
     }
     //4、删除数据表中的数据
     delete_data($this->table, $map);
     $this->success("删除成功");
 }
Ejemplo n.º 16
0
 /**
  *鐓х墖鎴栬棰慳jax鍒犻櫎
  *@author 鍒樻旦  <*****@*****.**>
  *@time 2015-07-07
  **/
 public function del()
 {
     if (session('home_shop_id')) {
         $resource_id = I('resources');
         //鏌ヨ璁板綍
         $resource_info = get_info($this->table, array('id' => $resource_id));
         //鍒犻櫎璁板綍
         $result = delete_data($this->table, array('id' => $resource_id));
         if ($result) {
             //鍒犻櫎鐪熸鐨勬枃浠�
             unlink($resource_info['img_path']);
             //鍒犻櫎鐪熺殑鏂囦欢
             $this->ajaxReturn(array('status' => 1, 'info' => '鍒犻櫎鎴愬姛锛侊紒'));
         } else {
             $this->ajaxReturn(array('status' => 0, 'info' => '鍒犻櫎澶辫触锛侊紒'));
         }
     } else {
         $this->ajaxReturn(array('status' => 0, 'info' => '闈炴硶鎿嶄綔锛�'));
     }
 }
Ejemplo n.º 17
0
function repopulate_acl($granular_access)
{
    $ia = elgg_set_ignore_access(true);
    $dbprefix = elgg_get_config('dbprefix');
    // empty the acl first
    $q = "DELETE FROM {$dbprefix}access_collection_membership\n\t\tWHERE access_collection_id = {$granular_access->acl_id}";
    delete_data($q);
    //loop through all of the guids this acl encompasses
    $list = (array) $granular_access->access_list;
    foreach ($list as $l) {
        $e = get_entity($l);
        if (elgg_instanceof($e, 'user')) {
            add_user_to_access_collection($e->guid, $granular_access->acl_id);
            continue;
        }
        if (elgg_instanceof($e, 'group')) {
            add_group_to_access_collection($e, $granular_access->acl_id);
            continue;
        }
        //@TODO - anything to do here?
    }
    elgg_set_ignore_access($ia);
}
Ejemplo n.º 18
0
/**
 * DB Based session handling code.
 */
function __elgg_session_gc($maxlifetime)
{
    global $DB_PREFIX;
    $life = time() - $maxlifetime;
    try {
        return (bool) delete_data("DELETE from {$DB_PREFIX}users_sessions where ts<'{$life}'");
    } catch (DatabaseException $e) {
        // Fall back to file store in this case, since this likely means that the database hasn't been upgraded
        global $sess_save_path;
        foreach (glob("{$sess_save_path}/sess_*") as $filename) {
            if (filemtime($filename) < $life) {
                @unlink($filename);
            }
        }
    }
    return true;
}
Ejemplo n.º 19
0
 public function del()
 {
     //1、根据点击删除传递过来的ID获取相关数据
     $ids = I('ids');
     $map['id'] = array("in", $ids);
     $result = get_result($this->table, $map);
     //2、获取内容中的图片并删除
     foreach ($result as $key => $value) {
         //删除封面
         if (file_exists($value['cover'])) {
             @unlink($value['cover']);
         }
         //删除内容中的图片
         delStrImgs($value['content']);
     }
     //3、删除数据表中的数据
     delete_data($this->table, $map);
     $this->success("删除成功");
 }
Ejemplo n.º 20
0
 * @author Shahriar
 * @version 1.0.1
*/
$data = json_decode(file_get_contents("php://input"));
if (!$data) {
    die;
}
$sub = mysql_real_escape_string($data->sub);
if ($sub == 'addDoa') {
    // Add New Doa
    $args = array('doa_name' => $data->doaName, 'doa_details' => $data->doaDet, 'doa_lang' => $data->doaLang, 'doa_type' => $data->doaType);
    $chk = insert_data('q_doa', $args);
    if ($chk) {
        echo success_json();
    } else {
        echo err_json();
    }
} elseif ($sub == 'getDoa') {
    // Get all Doa list
    print_r(table_data('q_doa', '1', 'doa_id,doa_name,doa_type,doa_lang'));
} elseif ($sub == 'delDoa') {
    // Delete Doa
    $chk = delete_data('q_Doa', "doa_id='{$data->doaID}'");
    if ($chk) {
        success_json();
    } else {
        echo err_json();
    }
} else {
    echo err_json();
}
Ejemplo n.º 21
0
                // It's now safe to delete the annotation
                $annotations_to_delete[] = $annotation->id;
                $success_count++;
            } else {
                register_error(elgg_echo('upgrade:timestamp_update_failed', array($annotation->id)));
                $error_count++;
            }
        } else {
            register_error(elgg_echo('discussion:upgrade:replies:create_failed', array($annotation->id)));
            $error_count++;
        }
    }
    if ($annotations_to_delete) {
        $annotation_ids = implode(",", $annotations_to_delete);
        $delete_query = "DELETE FROM {$db_prefix}annotations WHERE id IN ({$annotation_ids})";
        delete_data($delete_query);
    }
    // update the last action on containers to be the max of all its replies
    // or its own last action
    $reply_subtype_id = get_subtype_id('object', 'discussion_reply');
    foreach (array_unique($container_guids) as $guid) {
        // can't use a subquery in an update clause without hard to read tricks.
        $max = get_data_row("SELECT MAX(time_updated) as max_time_updated\n\t\t\t\t\tFROM {$db_prefix}entities e\n\t\t\t\t\tWHERE e.container_guid = {$guid}\n\t\t\t\t\tAND e.subtype = {$reply_subtype_id}");
        $query = "\n\t\tUPDATE {$db_prefix}entities\n\t\t\tSET last_action = '{$max->max_time_updated}'\n\t\t\tWHERE guid = {$guid}\n\t\t\tAND last_action < '{$max->max_time_updated}'\n\t\t";
        update_data($query);
    }
} while (microtime(true) - $START_MICROTIME < $batch_run_time_in_secs);
access_show_hidden_entities($access_status);
// replace events and hooks
_elgg_services()->events = $original_events;
_elgg_services()->hooks = $original_hooks;
Ejemplo n.º 22
0
/**
 * This function creates an archive copy of the system log.
 *
 * @param int $offset An offset in seconds from now to archive (useful for log rotation)
 *
 * @return bool
 */
function archive_log($offset = 0)
{
    global $CONFIG;
    $offset = (int) $offset;
    $now = time();
    // Take a snapshot of now
    $ts = $now - $offset;
    // create table
    $query = "CREATE TABLE {$CONFIG->dbprefix}system_log_{$now} as\n\t\tSELECT * from {$CONFIG->dbprefix}system_log WHERE time_created<{$ts}";
    if (!update_data($query)) {
        return false;
    }
    // delete
    // Don't delete on time since we are running in a concurrent environment
    if (delete_data("DELETE from {$CONFIG->dbprefix}system_log WHERE time_created<{$ts}") === false) {
        return false;
    }
    // alter table to engine
    if (!update_data("ALTER TABLE {$CONFIG->dbprefix}system_log_{$now} engine=archive")) {
        return false;
    }
    return true;
}
Ejemplo n.º 23
0
/**
 * Removes all relationships originating from a particular entity
 *
 * @param int    $guid                 GUID of the subject or target entity (see $inverse)
 * @param string $relationship         Type of the relationship (optional, default is all relationships)
 * @param bool   $inverse_relationship Is $guid the target of the deleted relationships? By default, $guid is the
 *                                     subject of the relationships.
 * @param string $type                 The type of entity related to $guid (defaults to all)
 *
 * @return true
 */
function remove_entity_relationships($guid, $relationship = "", $inverse_relationship = false, $type = '')
{
    global $CONFIG;
    $guid = (int) $guid;
    if (!empty($relationship)) {
        $relationship = sanitize_string($relationship);
        $where = "AND er.relationship = '{$relationship}'";
    } else {
        $where = "";
    }
    if (!empty($type)) {
        $type = sanitize_string($type);
        if (!$inverse_relationship) {
            $join = "JOIN {$CONFIG->dbprefix}entities e ON e.guid = er.guid_two";
        } else {
            $join = "JOIN {$CONFIG->dbprefix}entities e ON e.guid = er.guid_one";
            $where .= " AND ";
        }
        $where .= " AND e.type = '{$type}'";
    } else {
        $join = "";
    }
    $guid_col = $inverse_relationship ? "guid_two" : "guid_one";
    delete_data("\n\t\tDELETE er FROM {$CONFIG->dbprefix}entity_relationships AS er\n\t\t{$join}\n\t\tWHERE {$guid_col} = {$guid}\n\t\t{$where}\n\t");
    return true;
}
Ejemplo n.º 24
0
/**
 * Custom annotations delete function because logged out users can't delete annotations
 *
 * @param array $annotations annotations to delete
 *
 * @return void
 */
function group_tools_delete_annotations($annotations)
{
    if (!empty($annotations) && is_array($annotations)) {
        $dbprefix = elgg_get_config("dbprefix");
        foreach ($annotations as $annotation) {
            if (elgg_trigger_event("delete", "annotation", $annotation)) {
                delete_data("DELETE from {$dbprefix}annotations where id=" . $annotation->id);
            }
        }
    }
}
Ejemplo n.º 25
0
/**
 * Remove expired tokens
 *
 * @return bool
 * @since 1.7.0
 */
function remove_expired_user_tokens()
{
    global $CONFIG;
    $site_guid = $CONFIG->site_id;
    $time = time();
    return delete_data("DELETE from {$CONFIG->dbprefix}users_apisessions\n\t\twhere site_guid={$site_guid} and expires < {$time}");
}
/**
 * Removes all arbitrary relationships originating from a particular entity
 *
 * @param int    $guid_one     The GUID of the entity
 * @param string $relationship The name of the relationship (optional)
 * @param bool   $inverse      Whether we're deleting inverse relationships (default false)
 * @param string $type         The type of entity to the delete to (defaults to all)
 *
 * @return bool Depending on success
 */
function remove_entity_relationships($guid_one, $relationship = "", $inverse = false, $type = '')
{
    global $CONFIG;
    $guid_one = (int) $guid_one;
    if (!empty($relationship)) {
        $relationship = sanitise_string($relationship);
        $where = "and er.relationship='{$relationship}'";
    } else {
        $where = "";
    }
    if (!empty($type)) {
        $type = sanitise_string($type);
        if (!$inverse) {
            $join = " join {$CONFIG->dbprefix}entities e on e.guid = er.guid_two ";
        } else {
            $join = " join {$CONFIG->dbprefix}entities e on e.guid = er.guid_one ";
            $where .= " and ";
        }
        $where .= " and e.type = '{$type}' ";
    } else {
        $join = "";
    }
    if (!$inverse) {
        $sql = "DELETE er from {$CONFIG->dbprefix}entity_relationships as er\n\t\t\t{$join}\n\t\t\twhere guid_one={$guid_one} {$where}";
        return delete_data($sql);
    } else {
        $sql = "DELETE er from {$CONFIG->dbprefix}entity_relationships as er\n\t\t\t{$join} where\n\t\t\tguid_two={$guid_one} {$where}";
        return delete_data($sql);
    }
}
Ejemplo n.º 27
0
/**
 * Delete river items
 *
 * @warning not checking access (should we?)
 *
 * @param array $options Parameters:
 *   ids                  => INT|ARR River item id(s)
 *   subject_guids        => INT|ARR Subject guid(s)
 *   object_guids         => INT|ARR Object guid(s)
 *   target_guids         => INT|ARR Target guid(s)
 *   annotation_ids       => INT|ARR The identifier of the annotation(s)
 *   action_types         => STR|ARR The river action type(s) identifier
 *   views                => STR|ARR River view(s)
 *
 *   types                => STR|ARR Entity type string(s)
 *   subtypes             => STR|ARR Entity subtype string(s)
 *   type_subtype_pairs   => ARR     Array of type => subtype pairs where subtype
 *                                   can be an array of subtype strings
 *
 *   posted_time_lower    => INT     The lower bound on the time posted
 *   posted_time_upper    => INT     The upper bound on the time posted
 *
 * @return bool
 * @since 1.8.0
 */
function elgg_delete_river(array $options = array())
{
    global $CONFIG;
    $defaults = array('ids' => ELGG_ENTITIES_ANY_VALUE, 'subject_guids' => ELGG_ENTITIES_ANY_VALUE, 'object_guids' => ELGG_ENTITIES_ANY_VALUE, 'target_guids' => ELGG_ENTITIES_ANY_VALUE, 'annotation_ids' => ELGG_ENTITIES_ANY_VALUE, 'views' => ELGG_ENTITIES_ANY_VALUE, 'action_types' => ELGG_ENTITIES_ANY_VALUE, 'types' => ELGG_ENTITIES_ANY_VALUE, 'subtypes' => ELGG_ENTITIES_ANY_VALUE, 'type_subtype_pairs' => ELGG_ENTITIES_ANY_VALUE, 'posted_time_lower' => ELGG_ENTITIES_ANY_VALUE, 'posted_time_upper' => ELGG_ENTITIES_ANY_VALUE, 'wheres' => array(), 'joins' => array());
    $options = array_merge($defaults, $options);
    $singulars = array('id', 'subject_guid', 'object_guid', 'target_guid', 'annotation_id', 'action_type', 'view', 'type', 'subtype');
    $options = _elgg_normalize_plural_options_array($options, $singulars);
    $wheres = $options['wheres'];
    $wheres[] = _elgg_get_guid_based_where_sql('rv.id', $options['ids']);
    $wheres[] = _elgg_get_guid_based_where_sql('rv.subject_guid', $options['subject_guids']);
    $wheres[] = _elgg_get_guid_based_where_sql('rv.object_guid', $options['object_guids']);
    $wheres[] = _elgg_get_guid_based_where_sql('rv.target_guid', $options['target_guids']);
    $wheres[] = _elgg_get_guid_based_where_sql('rv.annotation_id', $options['annotation_ids']);
    $wheres[] = _elgg_river_get_action_where_sql($options['action_types']);
    $wheres[] = _elgg_river_get_view_where_sql($options['views']);
    $wheres[] = _elgg_get_river_type_subtype_where_sql('rv', $options['types'], $options['subtypes'], $options['type_subtype_pairs']);
    if ($options['posted_time_lower'] && is_int($options['posted_time_lower'])) {
        $wheres[] = "rv.posted >= {$options['posted_time_lower']}";
    }
    if ($options['posted_time_upper'] && is_int($options['posted_time_upper'])) {
        $wheres[] = "rv.posted <= {$options['posted_time_upper']}";
    }
    // see if any functions failed
    // remove empty strings on successful functions
    foreach ($wheres as $i => $where) {
        if ($where === false) {
            return false;
        } elseif (empty($where)) {
            unset($wheres[$i]);
        }
    }
    // remove identical where clauses
    $wheres = array_unique($wheres);
    $query = "DELETE rv.* FROM {$CONFIG->dbprefix}river rv ";
    // remove identical join clauses
    $joins = array_unique($options['joins']);
    // add joins
    foreach ($joins as $j) {
        $query .= " {$j} ";
    }
    // add wheres
    $query .= ' WHERE ';
    foreach ($wheres as $w) {
        $query .= " {$w} AND ";
    }
    $query .= "1=1";
    return delete_data($query);
}
Ejemplo n.º 28
0
/**
 * Garbage collect stub and fragments from any broken delete/create calls
 *
 * @return void
 * @elgg_plugin_hook_handler gc system
 * @access private
 */
function entities_gc()
{
    global $CONFIG;
    $tables = array('sites_entity', 'objects_entity', 'groups_entity', 'users_entity');
    foreach ($tables as $table) {
        delete_data("DELETE from {$CONFIG->dbprefix}{$table}\n\t\t\twhere guid NOT IN (SELECT guid from {$CONFIG->dbprefix}entities)");
    }
}
Ejemplo n.º 29
0
/**
 * Clear all the annotations for a given entity, assuming you have access to that metadata.
 * 
 * @param int $guid
 */
function clear_annotations($guid, $name = "")
{
    global $CONFIG;
    $guid = (int) $guid;
    if (!empty($name)) {
        $name = get_metastring_id($name);
    }
    $entity_guid = (int) $guid;
    if ($entity = get_entity($entity_guid)) {
        if ($entity->canEdit()) {
            $where = array();
            if ($name != "") {
                $where[] = " name_id='{$name}'";
            }
            $query = "DELETE from {$CONFIG->dbprefix}annotations where entity_guid={$guid} ";
            foreach ($where as $w) {
                $query .= " and {$w}";
            }
            return delete_data($query);
        }
    }
}
Ejemplo n.º 30
0
 function del()
 {
     $ids = I('ids');
     // 		dump($ids);die;
     if (is_array($ids)) {
         $map['id'] = array('in', $ids);
         $result = delete_data($this->table, $map);
         $ids_str = implode(',', $ids);
         if ($result) {
             action_log($this->table, $ids);
             // 				if($ids_str!=''){
             // 					execute_sql('house', 'update sr_house set '.$this->property_type.'=0 where id in ('.$ids_str.')');
             // 				}
             $this->success('操作成功', U('index'));
         } else {
             $this->error($result);
         }
     } else {
         $ids = intval($ids);
         $map['id'] = $ids;
         $result = delete_data($this->table, $map);
         if ($result) {
             // 				execute_sql('house', 'update sr_house set '.$this->property_type.'=0 where id='.$ids);
             action_log($this->table, $ids);
             $this->success('操作成功', U('index'));
         } else {
             $this->error($result);
         }
     }
 }